#ifndef __VERTEXARRAY_HPP__
#define __VERTEXARRAY_HPP__
#include "Buffers.hpp"

class VertexArray
{
public:
    VertexArray()
    {
        glGenVertexArrays(1, &id);
    }
    ~VertexArray()
    {
        //if(!id) this->Delete();
    }
    GLuint getID() { return id;}
    void bind() {glBindVertexArray(id);}
    void unbind() {glBindVertexArray(0);}
    void Delete() {glDeleteVertexArrays(1,&id);id = 0;}
    void addVBO(VertexBuffer &vbo, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)
    {
        this->bind();
        vbo.bind();
        glVertexAttribPointer(index, size, type, normalized, stride, pointer);
        glEnableVertexAttribArray(index);
        vbo.unbind();
        this->unbind();
    }
    void setEBO(IndexBuffer &ebo)
    {
        this->bind();
        ebo.bind();
        this->unbind();
        ebo.unbind();
    }
private:
    GLuint id;
};
#endif